package click


class StatisticsJob {
    //def timeout = 5000l // execute job once in 5 seconds
    static triggers = {
        cron name: 'StatisticsTrigger', cronExpression: "0 0 2 * * ?"
        //cron name: 'StatisticsTrigger', cronExpression: "0 * * * * ?"
    }
    def execute() {
        // execute task
        Calendar   calendar   =   Calendar.getInstance();   //获取日历  
//        calendar.set(Calendar.HOUR,0)
//        calendar.set(Calendar.MINUTE,0)
//        def end = calendar.getTime()
        calendar.add(Calendar.DAY_OF_MONTH,-1) 
//        def start = calendar.getTime()

        def statistics = new Statistics(lastTime : calendar.getTime())
        statistics.content = Ip.statistics()

        statistics.save();
        
        println "StatisticsJob Success! ${new Date()}"
        //calendar.set(Calendar.DAY_OF_WEEK,   Calendar.MONDAY);   //将日历翻到这周的周一  
        //System.out.println(calendar.getTime());  
    }
}
